<template>
	<view>
		<view class="">
			<scroll-view scroll-x class="bg-white nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="index==TabCur?'text-blue cur':''" v-for="(item,index) in tabs" :key="index" @tap="tabSelect(index)">
						{{item.name}}
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="">
			<swiper class="swiper" :style="'height:calc(100vh - '+ barHeight +'px);'" :current="TabCur" :indicator-dots="false" @change="swipChange">
				<swiper-item v-for="(item, index) in tabs" :key="index">
					<publist :state="item.type"></publist>
				</swiper-item>
			</swiper>
		</view>
		<view class="padding bottom-pub"  >
			<button @tap="pub" class="bg-blue sm">新增发布</button>
		</view>
	</view>
</template>

<script>
	import publist from "../../components/publist2.vue";
	export default {
		data() {
			return {
				tabs: [
					{name: '全部', type: '0'}, 
					{name: '展示中', type: '1'}, 
					{name: '审核中', type: '2'},
					{name: '已关闭', type: '3'},
					{name: '已拒绝', type: '4'},
				],
				TabCur: 0,
				barHeight: 100,
			}
		},

		onLoad(option) {
			this.barHeight = this.StatusBar + 100;
		},
		components: {
			publist
		},
		methods: {
			pub(){
				
			},
			tabSelect(index) {
				this.TabCur = index;
			},
			// 滑动 change
			swipChange(e){
				this.TabCur = e.detail.current;
			},
			pub(){
				let self = this;
				uni.showActionSheet({
				    itemList: ['发布招聘信息', '发布求职信息'],
				    success: function (res) {
				        if(1 == res.tapIndex){
							self.open(0)
						}else{
							self.open(1)
						}
				    },
				    fail: function (res) {
				        
				    }
				});
			},
			open: function(type) {
				/*
				if(1 == type){
					uni.navigateTo({
						url: '/pages/pub/history'
					})
					return
				}*/
				uni.navigateTo({
					url: '/pages/pub/recpub?type=' + type
				})
			},
			del(item) {
				let ancId = item.ancId;
				let _this = this;
				uni.showModal({
					content: '确定取消发布？',
					success(res) {
						if (res.confirm) {
							//uni.showLoading({mask:true});
							/*this.$request.put({url:'api/driver/info/down', data:{ ancId}}).then(res => {
				            uni.showToast({
				              title: '删除成功'
				            });
							uni.hideLoading();
				             _this.getData(1)
				          },res => {
											
							}),*/
							uni.showLoading({
								mask: true
							});
							_this.$request.put({
								url: 'api/driver/info/down',
								data: {
									ancId
								}
							}).then(res => {
									if (res.success) {
										uni.showToast({
											title: '删除成功'
										});
										uni.hideLoading();
										_this.getData(1)
									} else {
										uni.showToast({
											title: res.info
										});
									}
								},
								res => {
									uni.showToast({
										title: '删除失败'
									});
								})
						}
					}
				})
			}
		}
	}
</script>